package com.intelligent.ispc.common.utils;

import java.util.regex.Pattern;

/**
 * Created by Peter on 15/12/2.
 */
public class StringUtils extends org.apache.commons.lang3.StringUtils {

    public static boolean isNumeric(String str) {
        if (StringUtils.isBlank(str)) {
            return false;
        }
        Pattern pattern = Pattern.compile("-?[0-9]*(\\.?)[0-9]*");
        return pattern.matcher(str).matches();
    }

    public static boolean isSpecialBlank(String d) {
        if (StringUtils.isBlank(d)) {
            return true;
        }

        if (d.equalsIgnoreCase("N/A") || d.equalsIgnoreCase("-")
                || d.equalsIgnoreCase("nil") || d.equalsIgnoreCase("UnKown Line") ||
                d.equalsIgnoreCase("_")) {
            return true;
        }

        return false;
    }

    //lose UnKown Line
    public static boolean isBlankWithSpecialNumber(String d) {
        if (StringUtils.isBlank(d)) {
            return true;
        }

        if (d.equalsIgnoreCase("null") || d.equalsIgnoreCase("N/A") || d.equalsIgnoreCase("-") || d.equalsIgnoreCase("NaN")
                || d.equalsIgnoreCase("nil") || d.equalsIgnoreCase("_")) {
            return true;
        }

        return false;
    }
}
